<!DOCTYPE html>
<html>

<head>
    <title>游记收藏</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/travel.css"/>
    <script src="/js/plugins/jquery-form/jquery.form.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <script src="/js/common.js"></script>
    <link rel="stylesheet" href="/css/strategyCatalogs.css"/>
    <link rel="stylesheet" href="/css/userProfiles.css">


</head>

<body>

<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="javascript:history.go(-1);">
                <span><i class="fa fa-chevron-left" ></i></span>
            </a>
        </div>
        <div class="col">
            <span>点评收藏</span>
        </div>
        <div class="col"></div>
        <div class="col"></div>
    </div>
</div>
<br><br>
<div id="comment">
    <div render-loop="list">
        <div class="container row comment">
            <div class="col-2 comment-head">
                <a href="/mine/userProfiles.html?id=" render-fun="setHref" render-key="list.user.id">
                    <img class="rounded-circle" width="100%"
                         render-src="list.user.headImgUrl">
                </a>
            </div>
            <div class="col comment-right">
                <p class="authorName"><span render-html="list.user.nickName"></span></p>
                <span class="comment-star" render-fun="setStar" render-key="list.starNum">
                    <i class="fa fa-star"></i>
                    <i class="fa fa-star"></i>
                    <i class="fa fa-star"></i>
                    <i class="fa fa-star"></i>
                    <i class="fa fa-star-o"></i>
                </span>
                <span class="comment-date" render-html="list.createTime"></span>&nbsp;&nbsp;&nbsp;
                <span><i class="fa fa-trash deleteCollectBtn" style="color: mediumvioletred"></i><input type="hidden" render-value="list.id"/></span>
                <div class="comment-content">
                    <a href="/strategyComment.html?id=" render-fun="setHref" render-key="list.id">
                        <p render-html="list.content"></p>
                    </a>
                </div>

                <ul class="comment-img" render-fun="setImg" render-key="list.imgUrls">
                    <li>
                        <img render-src="" width="100%">
                    </li>
                </ul>

                <div class="comment-link">
                    <a href="/strategyCatalogs.html?id=" render-fun="setHref" render-key="list.strategy.id">
                        <img render-src="list.strategy.coverUrl"> <span render-html="list.strategy.title"></span>
                        <i class="fa fa-angle-right fa-2x"></i>
                    </a>
                </div>

            </div>
        </div>
    </div>
</div>


<script>
    var userStr = sessionStorage.getItem("user");
    var user;
    if (userStr) {
        user = JSON.parse(userStr);
    }

    var commentId;
    $.get("/strategyComments/commentCollect",{"userId":user.id},function (data) {
        $("#comment").renderValues({"list":data},{
            setHref:setHref,
            setStar:function (item,value) {
                var starthtml = '';
                var unStarthtml = '';
                var value = parseInt(value);

                for (var i = 0; i < value; i++) {
                    starthtml += '<i class="fa fa-star"></i>';
                }
                for (var i = 0; i < 5 - value; i++) {
                    unStarthtml +='<i class="fa fa-start-o"></i>'
                }
                $(item).html(starthtml + unStarthtml);
            },
            setImg:function (item, urls) {
                var imgUrls = urls.split(";");
                var imgs = "";
                $.each(imgUrls,function (index, ele) {
                    if(ele){
                        imgs += '<li><img src="' + ele + '"/></li>'
                    }
                });
                $(item).html(imgs);
            }

        });


        $(".deleteCollectBtn").click(function () {
            commentId = $(this).next("input").val();
            console.log(commentId);
            $(document).dialog({
                type: 'confirm',
                closeBtnShow: true,
                content: '确认删除吗 ~',
                onClickConfirmBtn: function () {
                    $.ajax({
                        type: "DELETE",
                        url: "/strategyComments/" + user.id,
                        data: {"commentId": commentId},
                        success: function (data) {
                            location.reload();
                        }

                    })
                }
            })
        });

    })






</script>

</body>

</html>